<?php

namespace App\Jobs;

use App\Repositories\UserRepository;
use App\User;
use App\UserMoneyLog;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class DisTributeSettlement implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected  $userMoneylog;
    protected  $userRepository;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(UserMoneyLog $userMoneyLog,$delay)
    {
        $this->delay(Carbon::now()->addDays($delay)); //延迟
        $this->userRepository=  new UserRepository();
        $this->userMoneylog=$userMoneyLog;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //收益结算
      $this->userRepository->setellement($this->userMoneylog->id);
    }
}
